<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;

class ProductDownCommand extends Command
{
    /**
     * 商品超时下架
     *
     * @var string
     */
    protected $signature = 'command:productDown';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * Execute the console command.
     */
    public function handle(): void
    {
        DB::table('shop_product')->leftJoin('shop_product_ext', 'shop_product_ext.product_id', 'shop_product.product_id')
            ->where('product_status', 2)
            ->whereRaw("product_special_start_time+shelf_day*86400+600<=unix_timestamp()")
            ->update(['product_status' => 1]);
    }
}
